package com.mingyizhudao.app.view.home.adapter;

import java.util.List;

import com.mingyizhudao.app.R;
import com.mingyizhudao.app.entity.DeptSubCatEntity;
import com.mingyizhudao.app.view.home.bean.DisNavsEntity;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class DeptListAdapter extends BaseAdapter{

	private Context mContext;
	private List<DeptSubCatEntity> subCat;
	private LayoutInflater inflater;
	public DeptListAdapter(Context context,List<DeptSubCatEntity> subCat) {
		this.mContext = context;
		this.subCat = subCat;
		this.inflater = LayoutInflater.from(mContext);
	}

	@Override
	public int getCount() {
		
		return subCat== null?0:subCat.size();
	}

	@Override
	public Object getItem(int arg0) {
		return subCat.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if(convertView == null){
			convertView = inflater.inflate(R.layout.lv_item_city, parent, false);//和城市共用了布局
			holder = new ViewHolder();
			holder.tv_city = (TextView) convertView.findViewById(R.id.tv_city);
			convertView.setTag(holder);
		}else{
			holder = (ViewHolder)convertView.getTag();
		}
		holder.tv_city.setText( subCat.get(position).getName() );
		return convertView;
	}

	public final class ViewHolder{

		public TextView	tv_city = null;
	}

}
